#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <list>

using namespace std;

class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        //write your code here
        unordered_map<int, int> hashtable;
for (int i = 0; i < nums.size(); ++i) {
auto it = hashtable.find(target - nums[i]);
if (it != hashtable.end()) {
return {it->second, i};
}
hashtable[nums[i]] = i;
}
return {};
    }
};
#ifndef onlineJudge
#include "header.cpp"
#endif

bool Test1()
{
    Solution s;
    vector<int> input{2,4,11,3};
    vector<int> result{0,1};
    vector<int> output = s.twoSum(input, 6);
    if(output == result) return true;
    return false;
}

bool Test2()
{
    Solution s;
    int target = -8;
    vector<int> input{-1,-2,-3,-4,-5};
    vector<int> result{2,4};
    vector<int> output = s.twoSum(input, target);
    if(output == result) return true;
    return false;
}

int main()
{
    int ret = 1;
    if(!Test1()) ret--;
    if(!Test2()) ret--;

    if(ret != 1) std::cout << "解答错误，未能通过测试用例" << std::endl;
    else std::cout << "通过全部测试用例" << std::endl;

    return 0;
}
